#ifndef gw_h
#define gw_h

#include <stdbool.h>
#include <sys/queue.h>

#include "scps_constants.h"

#include "scps.h"
#include "scpstp.h"

#define MAX_NUM_IF        3
#define MAX_ADDRS         4
#define MAX_MPF_ADDRS     4
#define MAX_NAME_LEN      80
#define DIVERT_START_RULE 10000  /* flush ipfw rules from here to +9 */
#define DEF_A_PORT        53000  /* Default divert port number for interface A */
#define DEF_B_PORT        53001  /* Default divert port number for i/f B */
#define DEF_C_PORT        53002  /* Default common divert port */


#define GATEWAY_LAN_SIDE  1
#define GATEWAY_WAN_SIDE  2

#define GW_MAX 1

struct gw {
  TAILQ_ENTRY(gw) entry;

  int id;
  char name[MAX_NAME_LEN];

  int wan;
  int wan_rxq;
  int wan_txq;

  int lan;
  int lan_rxq;
  int lan_txq;
  int use;
};

static inline bool valid_gw_id(int id)
{
  return id >= 0 && id < GW_MAX;
}

struct gw *gw_get(int id);

void gw_deinit(void);
void gw_init(void);

extern int debug_gw;

#define GW_LOG(fmt, ...)    \
  do {                      \
    if (debug_gw)         \
      print_log("[%s-%d]"fmt, __func__, __LINE__, ##__VA_ARGS__);\
  } while(0)
  

#endif
